package com.manlost.web.common.cookie;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * cookieName注解（定义一个cookie属性）
 * 
 * @author kang.zhouk
 *
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MLostCookieNamePolicy {

	/**
     * cookie domain property
     */
    CookieDomain domain() default CookieDomain.MANLOST_COM;
    
    /**
     * cookie max age property
     */
    int maxAge() default CookieMaxAge.TEMP;

    /**
     * cookie encrypt property
     * 
     * @return
     */
    boolean isEncrypt() default true;
    
    /**
     * cookie path property
     * 
     * @return
     */
    CookiePath path() default CookiePath.ROOT;

   
    boolean isSimpleValue() default false;

  
    public static class CookieMaxAge {

        /**
         * 会话级别cookie
         */
        public static final int TEMP    = -1;
        /**
         * 持久级别cookie
         */
        public static final int FOREVER = Integer.MAX_VALUE;
    }

   
    public static enum CookiePath {
    	
    	/**
    	 * 根目录下
    	 */
        ROOT("/");

        private String value;

        private CookiePath(String value) {
            this.value = value;
        }

        public String getValue() {
            return this.value;
        }
    }

    public static enum CookieDomain {
        
        /**
         * ManLost域下
         */
        MANLOST_COM(".manlost.com");

        private String value;

        private CookieDomain(String value) {
            this.value = value;
        }

        public String getValue() {
            return this.value;
        }
    }
}
